<?php

if (!defined('PUBLIC_HTML'))
{
	exit;
}

$user_id	= (isset($_GET['id'])) 		? (is_numeric($_GET['id']) ? intval($_GET['id']) : 0) : 0;
$submit		= (isset($_POST['submit'])) ? true : false;
$page_title = 'Are you sure you want to delete this user?';

if ($user_id == 0 || !$db->sql_count(TABLE_USERS, 'usr_id', $user_id) == 1)
{
	if (!$ajax)
	{
		redirect('cms.php?p=users');
	}
	exit;
}

$tpl_vars['ID'] = $user_id;

//$get_username = $db->sql_get_row(TABLE_USERS, 'usr_name', 'usr_id', $user_id);
$database->query("SELECT usr_name FROM " . TABLE_USERS . " WHERE usr_id = :usr_id");
$database->bind(':usr_id', $user_id);
$get_username = $database->single();
$tpl_vars['USERNAME'] = $get_username['usr_name'];

if ($submit)
{
	//$db->sql_delete_row(TABLE_USERS, 'usr_id', $user_id);
	$database->sqlDelete(TABLE_USERS, 'usr_id', $user_id);
	//redirect('cms.php?p=users');
	exit;
}

?>